package usaco.c2009.november.silver;
import java.util.Scanner;

/*
 * p3462
 * USACO 2009 November - Silver
 * Hint: Ford-Bellman algorithm for finding the shortest path when there is no negative cycle.
 */

public class p3462 {

	static int D, P, C, F, S;
	static int[][] m;
	static boolean[][] hasPath;
	static long[] dist;
	
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		D = scanner.nextInt();
		P = scanner.nextInt();
		C = scanner.nextInt();
		F = scanner.nextInt();
		S = scanner.nextInt();
		m = new int[C+1][C+1];
		hasPath = new boolean[C+1][C+1];
		for (int i=1;i<=P;++i) {
			int fr = scanner.nextInt();
			int to = scanner.nextInt();
			m[fr][to] = -D;
			hasPath[fr][to] = true;
		}
		for (int i=1;i<=F;++i) {
			int fr = scanner.nextInt();
			int to = scanner.nextInt();
			int co = scanner.nextInt();
			m[fr][to] = co-D;
			hasPath[fr][to] = true;
		}
		
		dist = new long[C+1];
		for (int i=1;i<=C;++i) {
			dist[i] = Integer.MAX_VALUE;
		}
		dist[S] = 0;
		boolean stop = true;
		for (int i=1;i<=C;++i) {
			stop = true;
			for (int j=1;j<=C;++j) {
				for (int k=1;k<=C;++k) {
					if (hasPath[j][k]) {
						if (dist[k] > (dist[j] + m[j][k])) {
							dist[k] = dist[j] + m[j][k];
							stop = false;
						}
					}
				}
			}
			if (stop) {
				break;
			}
		}
		
		if (!stop) {
			System.out.println(-1);
		}
		else {
			long min = Long.MAX_VALUE;
			for (int i=1;i<=C;++i) {
				if (dist[i] < min) {
					min = dist[i];
				}
			}
			System.out.println(D - min);
		}

	}

}
